﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Per_pixel_OCR
{
    public enum FeatureType
    {
        MINUS = 0,
        PLUS = 1,
    }

    public class Feature
    {
        public static Random rnd = new Random();

        public FeatureType FeatureType { get; private set; }

        public int Threshold { get; private set; }

        public int Offset1X { get; private set; }
        public int Offset1Y { get; private set; }
        
        public int Offset2X { get; private set; }
        public int Offset2Y { get; private set; }

        public Feature(FeatureType fType)
        {
            this.FeatureType = fType;

            this.Offset1X = rnd.Next(Parameters.FeatureRange * 2) - Parameters.FeatureRange;
            this.Offset1Y = rnd.Next(Parameters.FeatureRange * 2) - Parameters.FeatureRange;

            this.Offset2X = rnd.Next(Parameters.FeatureRange * 2) - Parameters.FeatureRange;
            this.Offset2Y = rnd.Next(Parameters.FeatureRange * 2) - Parameters.FeatureRange;

            if (this.FeatureType == FeatureType.MINUS)
                this.Threshold = Parameters.MinusThresholdCandidates[rnd.Next(Parameters.MinusThresholdCandidates.Length)];
            else if (this.FeatureType == FeatureType.PLUS)
                this.Threshold = Parameters.PlusThresholdCandidates[rnd.Next(Parameters.PlusThresholdCandidates.Length)];
        }

        public override string ToString()
        {
            return "(" + this.Offset1X.ToString() + ", "+ this.Offset1Y.ToString() + "),(" + this.Offset2X.ToString() + ", " + this.Offset2Y.ToString() + ") " + this.FeatureType.ToString() + " Threshold: " + this.Threshold.ToString();
        }
    }
}
